<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%	
	//获取项目名
	String path = request.getContextPath();
	//获取tomcat 协议+地址+端口号+ 获取项目名
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	//out.println(basePath);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>网站后台管理模版</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath %>background/static/admin/layui/css/layui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath %>background/static/admin/css/admin.css" />
<script src="<%=basePath %>jquery-3.5.1.js"></script>
<script
	src="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<link rel="stylesheet"
	href="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/css/bootstrap.css">
<script src="<%=basePath %>js/content.js"></script>
<link rel="stylesheet" href="../css/sweetalert.css">
<script src="../js/sweetalert-dev.js"></script>
</head>
<body>

	<div class="wrap-container">
		
		<form class="layui-form" style="width: 90%; padding-top: 20px;">
			<div class="layui-form-item">
				<label class="layui-form-label">问题标题：</label>
				<div class="layui-input-block">
					<input id="qTitle" type="text" name="qTitle" required
						lay-verify="required" placeholder="请输入问题标题" autocomplete="off"
						class="layui-input">
				</div>

			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">问题具体内容：</label>
				<div class="layui-input-block">
					<input id="qContent" type="text" name="qContent" required
						lay-verify="required" placeholder="请输入问题具体内容" autocomplete="off"
						class="layui-input">
				</div>

			</div>

			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">提问userid</label>
				<div class="layui-input-block">
					<textarea id="userid" name="userid" placeholder="请输入userid"
						class="layui-input"></textarea>
				</div>
			</div>
			

			<div class="">
				<div class="layui-input-block">
					<!--lay-submit lay-filter="formDemo"  -->
					<button id="sub" class="layui-btn layui-btn-normal">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript" charset="utf-8">
		
			$("#sub").click(function(){
				var qTitle = $("#qTitle").val();
				var qContent = $("#qContent").val();
				var userid = $("#userid").val();
				
				//console.log("还能输出吗？");
				
				
				/* if(cProvince==null || cProvince==""){
					alert("请输入省份！");
					return;
				}
				
				if(cName==null || cName==""){
					alert("请输入院校名称！");
					return;
				}
				
				if(cLogo==null || cLogo==""){
					alert("请输入校徽地址！");
					return;
				} */
				
				$.ajax({
					url:"<%=basePath %>BackForumServlet",
					type:"get",
					data:"mark=addQuestion&qTitle="+qTitle+"&qContent="+qContent+"&userid="+userid,
					dataType:"json",
					success:function(mes){
						//console.log("mes:"+mes);
						if(mes==true){
							swal("添加成功",qTitle,"success")
							window.location.href = "<%=basePath %>BackForumServlet?mark=showQuestion";
							
						}else{
							alert("添加失败！");
							return;
						}
					},
				      error:function(mes){ // 这里是有bug的，但是为了能够跳转到展示页面，只好这么做了
				    	  if(mes!=null){
				    		  	console.log("是true");
								swal("添加成功",qTitle,"success")
								window.location.href = "<%=basePath %>BackForumServlet?mark=showQuestion";
								
							}else{
								console.log("是false");
								alert("添加失败！");
								return;
							}
				      }
				});
				
				
			})		
		</script>
	<script src="<%=basePath %>background/static/admin/layui/layui.js"
		type="text/javascript" charset="utf-8"></script>
	<script>
			//Demo
			layui.use(['form'], function() {
				var form = layui.form();
				form.render();
				//监听提交
				form.on('submit(formDemo)', function(data) {
					layer.msg(JSON.stringify(data.field));
					return false;
				});
			});
		</script>
</body>

</html>